﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartSpace.Core
{
    public interface ICoreService
    {
        User GetUser(string account);
        User GetUser(Guid id);
        List<User> GetUsers(List<Guid> idList);

        PagedList<Role> GetRoles(int start, int limit);
        PagedList<User> GetUsers(int start, int limit);
        PagedList<User> FindUsers(string filter, int start, int limit);
        Role GetRole(Guid roleId);

        bool AssignUser(Role role, User user, User assigner);
        bool RemoveUser(Role role, User user);

        bool StoreRole(Role role);
        bool StoreUser(User user);
        bool RemoveRole(Role role);
        bool RemoveUser(User user);

        List<Role> GetAssignedRoles(User user);

        List<User> GetContainsUsers(Role role);
        List<User> GetContainsUsers(Guid roleId);

        bool SaveModule(Module module);
        PagedList<Module> GetModules(int start, int limit);
        PagedList<Module> GetModules(string type, int start, int limit);
        Module GetModule(Guid moduleId);
        ModuleView GetView(Guid viewId);

        #region navigation
        bool StoreNavigation(Navigation navigation);
        Navigation GetNavigation(Guid id);
        bool SetDefaultNavigation(Guid id);
        List<Navigation> GetNavigations(Guid applicationId);
        Navigation GetDefaultNavigation(Guid applicationId);
        bool AddRoleNavigation(Guid navigationId, Guid roleId);
        bool DeleteRoleNavigation(Guid navigationId, Guid roleId);
        /// <summary>
        /// 批量设置角色的导航
        /// </summary>
        /// <param name="navigationIds"></param>
        /// <param name="roleId"></param>
        /// <returns></returns>
        bool SetRoleNavigations(List<Guid> navigationIds, Guid roleId);
        List<Navigation> GetNavigations(Guid applicationId, Guid roleId);
        List<Navigation> GetUserNavigations(Guid applicationId, Guid id);
        List<Navigation> GetUserNavigations(Guid applicationId, string account);
        #endregion

        #region shortcut
        bool AddShortcut(Guid navigationId, string caption);
        bool DeleteShortcut(Guid navigationId);
        List<Shortcut> GetShortcuts(Guid applicationId);
        List<Shortcut> GetShortcuts(Guid applicationId, Guid roleId);
        List<Shortcut> GetUserShortcuts(Guid applicationId, Guid id);
        List<Shortcut> GetUserShortcuts(Guid applicationId, string account);
        #endregion

        #region org
        bool SaveOrg(Org org);
        Org GetOrg(Guid orgId);
        Org GetOrg(string code);
        /// <summary>
        /// 获取父结点列表
        /// </summary>
        /// <param name="orgId"></param>
        /// <param name="rootId">查找到rootId为止</param>
        /// <returns></returns>
        List<Org> GetParentOrgs(Guid orgId, Guid rootId);
        List<Org> GetOrgs(Nullable<Guid> orgId, bool isRecursive);
        bool AddMember(Org org, User user, bool isMajor);
        bool AddMember(string code, string account, bool isMajor);
        bool RemoveMember(Org org, User user);
        PagedList<OrgMember> GetMembers(Org org, int start, int limit);
        List<OrgMember> GetPositions(Guid userId);
        List<OrgMember> GetPositions(string account);
        OrgMember GetMajorPosition(Guid userId);
        OrgMember GetMajorPosition(string account);
        #endregion

        #region application
        bool SaveApplication(Application app);
        Application GetApplication(Guid id);
        List<Application> GetApplications();
        List<Application> GetPersonalApplications(string account);
        Application GetPersonalDefaultApplication(string account);
        List<Application> GetApplications(string type);
        List<Application> GetPersonalApplications(string type, string account);
        Application GetPersonalDefaultApplication(string type, string account);
        bool AddModule(Guid applicationId, Guid moduleId);
        bool RemoveModule(Guid applicationId, Guid moduleId);
        List<Module> GetModules(Guid applicationId);
        #endregion

        #region Theme
        bool SaveTheme(Theme theme);
        List<Theme> GetThemes();
        List<Theme> GetThemes(string type);
        Theme GetTheme(Guid themeId);
        #endregion

        #region Image
        bool SaveImage(ImageFile image);
        bool DeleteImage(Guid imageId);
        ImageFile GetImage(Guid imageId);
        List<ImageFile> GetImages();
        #endregion
    }
}
